﻿@using NewLife.Cube
@using XCode
@{
    var entity = Model as IEntity;

    var rv = entity.GetRouteKey();
}
@if (this.Has(PermissionFlags.Update))
{
    <i class="glyphicon glyphicon-edit" style="color: blue;"></i>
    <a href="@Url.Action("Edit", rv)" class="editcell">编辑</a>
}
else if (this.Has(PermissionFlags.Detail))
{
    <i class="glyphicon glyphicon-edit" style="color: blue;"></i>
    <a href="@Url.Action("Detail", rv)" class="editcell">查看</a>
}
@if (this.Has(PermissionFlags.Delete))
{
    var fact = ViewBag.Factory as IEntityOperate;
    var fi = (fact == null || fact.Fields == null) ? null : fact.Fields.FirstOrDefault(e => e.Name.EqualIgnoreCase("Deleted", "IsDelete", "IsDeleted"));
    if (fi != null && fi.Type == typeof(Boolean) && (Boolean)entity[fi.Name])
    {
        <i class="glyphicon glyphicon-transfer" style="color: green;"></i>
        <a href="@Url.Action("Delete", rv)" data-action="action" data-confirm="确认恢复？">恢复</a>
    }
    else
    {
        <i class="glyphicon glyphicon-remove" style="color: red;"></i>
        <a href="@Url.Action("Delete", rv)" data-action="action" data-confirm="确认删除？">删除</a>
    }
}